﻿using System.Windows;
using ThePresenter.Properties;

namespace ThePresenter.Windows
{
	/// <summary>
	/// Interaction logic for StartupWindow.xaml
	/// </summary>
	public partial class StartupWindow : Window
	{
		#region Dependency property identifiers

		/// <summary>
		/// Identifies the <see cref="StartupMode"/> dependency property.
		/// </summary>
		/// <value>The identifier for the <see cref="StartupMode"/> dependency property.</value>
		public static readonly DependencyProperty StartupModeProperty = DependencyProperty.Register("StartupMode", typeof(StartupMode), typeof(StartupWindow));

		#endregion

		#region Properties

		/// <summary>
		/// Gets or sets the startup mode. This is a dependency property.
		/// </summary>
		/// <value>The startup mode.</value>
		public StartupMode StartupMode
		{
			get
			{
				return (StartupMode)GetValue(StartupModeProperty);
			}
			set
			{
				SetValue(StartupModeProperty, value);
			}
		}

		#endregion
		
		#region Constructors

		/// <summary>
		/// Initializes a new instance of the <see cref="StartupWindow"/> class.
		/// </summary>
		public StartupWindow()
		{
			InitializeComponent();

			StartupMode = Settings.Default.DefaultStartupMode;
		}

		#endregion

		#region Methods

		/// <summary>
		/// Handles the Click event of the StartButton control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
		private void StartButton_Click(object sender, RoutedEventArgs e)
		{
			// Save actual choice
			Settings.Default.DefaultStartupMode = StartupMode;
			Settings.Default.Save();
			this.DialogResult = true;
#if DEBUG
			// Debug.WriteLine(string.Format("Prompt selected StartupMode: {0}.", StartupMode));
#endif

			// Close this window
			Close();
		}

		#endregion
	}
}
